%% Analysis of Steady-State 25C vs. 37C BarSeq data from Mar. 3 2021 samples
load('EcoliBW25113_Tn_LB_25to37_20200303.mat');
temp = Upshifts_Mar3;
close all;

%% Create plotting arrays
time_25to37C = [-15 10 20 30 40 60 100];
fitness_array_25to37C = [temp.setAIT05433_25to37_15min_B temp.setAIT05633_25to37_10min_B temp.setAIT05733_25to37_20min_B temp.setAIT05833_25to37_30min_B temp.setAIT05933_25to37_40min_B temp.setAIT06033_25to37_60min_B temp.setAIT06133_25to37_100min_B];

time_25to25C = [-15 0 10 20 30 40 60 100];
fitness_array_25to25C = [temp.setAIT04433_25to25_15min_B temp.setAIT04533_25to25_0min_B temp.setAIT04633_25to25_10min_B temp.setAIT04733_25to25_20min_B temp.setAIT04833_25to25_30min_B temp.setAIT04933_25to25_40min_B temp.setAIT05033_25to25_60min_B temp.setAIT05133_25to25_90min_B];

% 40min timepoint removed (lower # reads)
time_25to25C = [-15 0 10 20 30 60 100];
fitness_array_25to25C = [temp.setAIT04433_25to25_15min_B temp.setAIT04533_25to25_0min_B temp.setAIT04633_25to25_10min_B temp.setAIT04733_25to25_20min_B temp.setAIT04833_25to25_30min_B temp.setAIT05033_25to25_60min_B temp.setAIT05133_25to25_90min_B];


%% Plot 25to37C data
hits_25to37C = [];

figure;
for k=1:size(fitness_array_25to37C,1)
    if mean(abs(fitness_array_25to37C(k,:)))<1
        plot(time_25to37C, fitness_array_25to37C(k,:), 'color', [0 0 0]+0.8);
    else
        plot(time_25to37C, fitness_array_25to37C(k,:), 'r');
        hits_25to37C = [hits_25to37C; k];
        text(time_25to37C(end), fitness_array_25to37C(k,end), temp.genename(k));
    end
    hold on;
end
ylim([-6 2]);
set(gcf, 'Position', [0 0 400 300]);
set(gca,'fontsize', 20);
box off;
xlabel('Time (min)');
ylabel('Log2 fitness');

%% Plot 25to25C data
hits_25to25C = [];

figure;
for k=1:size(fitness_array_25to25C,1)
    if mean(abs(fitness_array_25to25C(k,:)))<1
        plot(time_25to25C, fitness_array_25to25C(k,:), 'color', [0 0 0]+0.8);
    else
        plot(time_25to25C, fitness_array_25to25C(k,:), 'b');
        hits_25to25C = [hits_25to25C; k];
        text(time_25to25C(end), fitness_array_25to25C(k,end), temp.genename(k));
    end
    hold on;
end
ylim([-6 2]);
set(gcf, 'Position', [0 0 400 300]);
set(gca,'fontsize', 20);
box off;
xlabel('Time (min)');
ylabel('Log2 fitness');

%% Display hits
disp('25 to 37 hits');
temp.genename(hits_25to37C)
disp('25 to 25 hitsL');
temp.genename(hits_25to25C)